package com.firefightingiot.firefightingiot.web.web;

import cn.hutool.json.JSONObject;
import com.firefightingiot.firefightingiot.common.base.BaseController;
import com.firefightingiot.firefightingiot.support.annotaion.Action;
import com.firefightingiot.firefightingiot.support.annotaion.At;
import com.firefightingiot.firefightingiot.support.model.RespEntity;
import com.firefightingiot.firefightingiot.web.service.LEDScreenService;
import org.dom4j.DocumentException;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * @author Yang
 * LED控制器
 */
@Action
@RequestMapping("LEDScreen")
public class LEDScreenController extends BaseController {
    @Resource
    public LEDScreenService LEDScreenService;

    /**
     * @Author YangYu
     * @Description 发布文字
     * @Date Created in 17:22 2021/9/13
     *                   宽        高    特技类型    特技速度     停留时间   文字内容   字体大小   控制卡条形码
     * @Param [jsonParam：width、height、stuntType、stuntSpeed、stayTime、content、fontSize、number]
     */

    @At(value = "publishText", method = RequestMethod.POST)
    public RespEntity publishText(@RequestBody(required = false) JSONObject jsonParam) {
        return LEDScreenService.publishText(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 发布文字xml版
     * @Date Created in 15:13 2021/9/17
     * @Param [jsonParam]
     */

    @At(value = "publishTextXML", method = RequestMethod.POST)
    public RespEntity publishTextXML(@RequestBody(required = false) JSONObject jsonParam) throws IOException, DocumentException {
        return LEDScreenService.publishTextXML(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 发布视频
     * @Date Created in 17:47 2021/9/13
     * @Param [jsonParam]
     */

    @At(value = "publishVideo", method = RequestMethod.POST)
    public RespEntity publishVideo(@RequestBody(required = false) JSONObject jsonParam) throws IOException, DocumentException, InterruptedException {
        return LEDScreenService.publishVideo(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 发布图片
     * @Date Created in 10:18 2021/11/10
     * @Param [jsonParam]
     */

    @At(value = "publishPicture", method = RequestMethod.POST)
    public RespEntity publishPicture(@RequestBody(required = false) JSONObject jsonParam) throws IOException, DocumentException, InterruptedException {
        return LEDScreenService.publishPicture(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 屏幕截图
     * @Date Created in 17:34 2021/9/13
     *                    截图宽度   截图高度    控制卡条形码
     * @Param [jsonParam：picwidth、picheight、number]
     */

    @At(value = "screenshot", method = RequestMethod.POST)
    public RespEntity instructionEncryption(@RequestBody(required = false) JSONObject jsonParam){
        return LEDScreenService.screenshot(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 停止播放
     * @Date Created in 14:38 2021/9/16
     *                   节目类型 控制卡条形码
     * @Param [jsonParam:：type、number]
     */

    @At(value = "stopPlay", method = RequestMethod.POST)
    public RespEntity stopPlay(@RequestBody(required = false) JSONObject jsonParam){
        return LEDScreenService.stopPlay(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 播放节目
     * @Date Created in 9:31 2021/9/18
     * @Param [jsonParam]
     */

    @At(value = "play", method = RequestMethod.POST)
    public RespEntity play(@RequestBody(required = false) JSONObject jsonParam){
        return LEDScreenService.play(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 查询上传视频的文件名
     * @Date Created in 16:12 2021/10/11
     * @Param [jsonParam]
     */

    @At(value = "getLedUploadFileList", method = RequestMethod.GET)
    public RespEntity getLedUploadFileList(@RequestBody(required = false) JSONObject jsonParam){
        return LEDScreenService.getLedUploadFileList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 删除文件
     * @Date Created in 17:13 2021/11/9
     * @Param [jsonParam]
     */

    @At(value = "delFile", method = RequestMethod.POST, param = {"id"})
    public RespEntity delFile(@RequestBody(required = false) JSONObject jsonParam){
        return LEDScreenService.delFile(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设备发送tcp数据中转
     * @Date Created in 17:38 2021/9/13
     * @Param [jsonParam]
     */

    @At(value = "dataRelay", method = RequestMethod.POST)
    public RespEntity dataRelay(@RequestBody(required = false) JSONObject jsonParam) throws UnsupportedEncodingException, InterruptedException {
        return LEDScreenService.dataRelay(jsonParam);
    }
    @At(value = "test", method = RequestMethod.POST)
    public void java_XiuGai__XML(@RequestBody(required = false) JSONObject jsonParam) throws IOException, DocumentException {
         LEDScreenService.java_XiuGai__XML(jsonParam);
    }
}
